package com.cml.springcloud.controller;

import com.cml.springcloud.domain.CommonResult;
import com.cml.springcloud.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cml
 * @create 2021/4/29 15:55
 */
@RestController
@Slf4j
public class StorageController {
    @Autowired
    private StorageService storageService;

    //扣减库存
    @RequestMapping("/storage/decrease")
    public CommonResult decrease(Long productId, Integer count) {
//        try {
//            TimeUnit.SECONDS.sleep(20);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        storageService.decrease(productId, count);
        return new CommonResult(200,"扣减库存成功！");
    }

}
